package web

import (
	"crypto/sha256"
	"encoding/hex"
)

func GetSHA256HashCode(message []byte) string {
	//创建一个基于SHA256算法的hash.Hash接口的对象
	hash := sha256.New()
	//输入数据
	hash.Write(message)
	//计算哈希值
	bytes := hash.Sum(nil)
	//将字符串编码为16进制格式,返回字符串
	hashCode := hex.EncodeToString(bytes)
	//返回哈希值
	return hashCode
}

// checkUID 检测UID是否符合要求
func checkUID(uid string, uidsecret string) bool {

	if uid != "" && uidsecret != "" && GetSHA256HashCode([]byte(uid+solt)) == uidsecret {
		return true
	}

	return false
}
